<template>
    <h3>自定义v-model通过defineProps defineEmit</h3>
    <el-input v-model="value" clearable />
</template>
<script setup lang="ts">
import { ref, watch} from 'vue'

const props = defineProps({
    modelValue: {
        type: String,
        default: null
    }
})
const value = ref(props.modelValue)
watch(()=>props.modelValue, (val) => {
    value.value = val
})
const emit = defineEmits(['update:modelValue'])
watch(value, (val) => {
    emit('update:modelValue', val)
})
</script>
<style lang="scss" scoped>
.el-input{
    max-width: 200px;
}
</style>